//
//  MusicLBTDetailWebViewController.m
//  ToWhere
//
//  Created by dllo on 15/11/21.
//  Copyright © 2015年 www.TE.com. All rights reserved.
//

#import "MusicLBTDetailWebViewController.h"

@interface MusicLBTDetailWebViewController ()<UIWebViewDelegate>

@property(nonatomic, retain) UIWebView *webView;

@property(nonatomic, retain) UIView *titleView;

@end

@implementation MusicLBTDetailWebViewController

- (void)dealloc
{
    [_webUrl release];
    [_webView release];
    [_titleView release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //创建标题
    [self createTitle];
    
    //创建webView
    [self createWebView];
}

#pragma mark 创建标题
-(void)createTitle
{
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.titleView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,kHeight * 64)];
    self.titleView.backgroundColor = [[UIColor blackColor]colorWithAlphaComponent:1];
    [self.view addSubview:self.titleView];
    [self.titleView release];
    [_titleView release];
    
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.view.frame.size.width / 2 - 100 * kWidth, self.titleView.frame.size.height / 2 - 10 * kHeight, kWidth * 200, kHeight * 30)];
    titleLabel.text = self.name;
    titleLabel.font = [UIFont systemFontOfSize:17 * kWidth];
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    [self.titleView addSubview:titleLabel];
    [titleLabel release];
    
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    backBtn.frame = CGRectMake(15 * kWidth, 25 * kHeight, 20 * kWidth, 20 * kHeight);
    [backBtn setBackgroundImage:[UIImage imageNamed:@"Food_back"] forState:UIControlStateNormal];
    [self.titleView addSubview:backBtn];
    [backBtn addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];    
}

-(void)BackAction:(UIButton *)btn
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark 创建webView
-(void)createWebView
{
    //创建webView
    self.webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 64 * kHeight, self.view.frame.size.width, self.view.frame.size.height - 64 * kHeight)];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.webUrl]];
    
    [self.webView loadRequest:request];
    self.webView.delegate = self;
    [self.view addSubview:self.webView];
    //自动适应屏幕
    self.webView.scalesPageToFit = YES;
    //边界不回弹
    self.webView.scrollView.bounces = NO;
    //隐藏滑动线
    self.webView.scrollView.showsVerticalScrollIndicator = NO;
    [self.webView release];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
